/**
 * Version 14 mrt 2008 - initial version
 */
package audioreaper.machine;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <code>Effect</code>.
 *
 * @author <a href="mailto:vincent@nazarene.nl">Vincent van Beveren</a>
 *
 */
public abstract class Effect extends AbstractMachine implements Source, Target {

	private List<Source> _sources = new ArrayList<Source>();
	
	public Effect(MachineContext context) {
		super(context);
	}

	/* (non-Javadoc)
	 * @see vanbeveren.audioreaper.model.Target#getSourceList()
	 */
	@Override
	public List<Source> getSourceList() {
		return _sources;
	}
	
	@Override
	protected final void renderInactive() {
		Arrays.fill(_buffer, 0);
		int[] otherBuffer;
		for (int i = 0; i < _sources.size(); i++) {
			_sources.get(i).render();
			otherBuffer = _sources.get(i).getBuffer();
			for (int j = 0; j < otherBuffer.length; j++) {
				_buffer[j] += otherBuffer[j];				
			}
		}
	}	

}
